//The MIT License
//
//Copyright (c) 2009 nodchip
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
package tv.dyndns.kishibe.client.packet;

import java.util.HashSet;
import java.util.Set;

import tv.dyndns.kishibe.client.constant.Constant;
import tv.dyndns.kishibe.client.game.ProblemGenre;
import tv.dyndns.kishibe.client.game.ProblemType;
import tv.dyndns.kishibe.client.util.HasIndex;

import com.google.common.collect.ImmutableSet;
import com.google.gwt.user.client.rpc.IsSerializable;

public class PacketUserData implements IsSerializable {
	public static enum WebSocketUsage implements IsSerializable, HasIndex {
		Default(0), On(1), Off(2);
		private final int index;

		private WebSocketUsage(int index) {
			this.index = index;
		}

		@Override
		public int getIndex() {
			return index;
		}
	}

	public String playerName;
	public String greeting;
	public int highScore;
	public int averageScore;
	public int playCount;
	public int rating;
	public int levelName;
	public int levelNumber;
	public int prefecture;
	public float averageRank;
	public Set<ProblemGenre> genres;
	public Set<ProblemType> types;
	public int classLevel;
	public int userCode;
	public String imageFileName;
	public int[][][] correctCount;
	public boolean playSound;
	public boolean multiGenre;
	public boolean multiType;
	public int difficultSelect;
	public boolean rankingMove;
	public int bbsDispInfo;
	public boolean bbsAge;
	public boolean chat;
	public NewAndOldProblems newAndOldProblems;
	public Set<Integer> ignoreUserCodes;
	public int timerMode;
	public boolean publicEvent;
	public boolean hideAnswer;
	public boolean showInfo;
	public boolean reflectEventResult;
	public WebSocketUsage webSocketUsage;
	public int volatility;
	public boolean qwerty;
	public transient String openId;

	public PacketUserData() {
		playerName = "未初期化です";
		greeting = "よろしく～！";
		imageFileName = "noimage.jpg";
		correctCount = new int[ProblemGenre.values().length][ProblemType.values().length][2];
		playSound = false;
		rankingMove = true;
		rating = 1300;
		ignoreUserCodes = new HashSet<Integer>();
		bbsDispInfo = Constant.BBS_DISPLAY_INFO_ALL_DATA;
		bbsAge = true;
		timerMode = 0;
		prefecture = 0;
		genres = ImmutableSet.of();
		types = ImmutableSet.of();
		chat = true;
		publicEvent = true;
		showInfo = true;
		newAndOldProblems = NewAndOldProblems.Both;
		reflectEventResult = false;
		webSocketUsage = WebSocketUsage.Default;
		difficultSelect = Constant.DIFFICULT_SELECT_EASY;
	}

	public void setReflectEventResult(boolean reflectEventResult) {
		this.reflectEventResult = reflectEventResult;
	}

	public boolean isReflectEventResult() {
		return reflectEventResult;
	}
}
